# -*- encoding : utf-8 -*-
class CreateBookBorrows < ActiveRecord::Migration
  def change
    create_table :book_borrows do |t|
      t.integer :user_id
      t.integer :book_id
      t.datetime :borrowed_time
      t.datetime :return_time
      t.integer :status
      
      t.timestamps
    end
    
    add_index :book_borrows, :user_id
    add_index :book_borrows, :book_id
    
    add_foreign_key(:book_borrows, :users, column: 'user_id')
    add_foreign_key(:book_borrows, :books, column: 'book_id')
  end
end
